﻿using System.Collections.Generic;

namespace Sayook.Framework.Model
{
    /// <summary>
    /// 接口编号
    /// </summary>
    public class ApiInterfaceCode
    {
        private readonly Dictionary<string, int> _pairs;

        public ApiInterfaceCode(Dictionary<string, int> pairs)
        {
            _pairs = pairs;
        }

        public int GetCode(string key)
        {
            if (string.IsNullOrWhiteSpace(key) || _pairs == null) return -1;
            key = key.ToLower();
            if (!_pairs.ContainsKey(key))
            {
                return 0;
            }
            return _pairs[key];
        }
    }
}